<template>
  <div class="app">
    <form action>
      <input type="text" name="username" v-model="username" />
      <br />
      <input type="password" name="password" v-model="password" />
      <br />
      <button @click="putLogin">提交登录</button>
    </form>

    <button @click="getHomeData">请求home页面的数据</button>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      username: "",
      password: "",
    };
  },
  //生命周期 - 创建完成
  created() {},

  //DOM挂载完毕
  mounted() {},
  methods: {
    async getHomeData() {
      let res = await axios.get("/api/home");
      console.log(res);
    },

    async putLogin() {
      let data = await axios.post("/api/login", {
        username: this.username,
        password: this.password,
      });
      console.log(data);
    },
  },
};
</script>

<style lang='less' scoped>
</style>